<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script
      type="text/javascript"
      src="https://oodocsdev.yxuer.com/web-apps/apps/api/documents/api.js"
    ></script>
    <style>
      html {
        height: 100%;
        width: 100%;
        padding: 0;
        margin: 0;
      }
      body {
        height: 100%;
        width: 100%;
        padding: 0;
        margin: 0;
        display: flex;
        justify-content: space-between;
      }
      .rightText {
        position: absolute;
        right: 0;
        width: 300px;
      }
    </style>
  </head>
  <body>
    <div id="placeholder"></div>
    <!-- <div class="rightText">
      <textarea
        name=""
        id=""
        placeholder="请输入文本内容"
        style="width: 100%"
      ></textarea>
      <button onclick="insertText()">插入文字</button>
    </div> -->
    <script>
      var docEditor = new DocsAPI.DocEditor("placeholder", {
        document: {
          fileType: "doc",
          title: "xxx.xls",
          //地址必须文件服务器能访问到
          url: "https://origin.yxuer.com/1fbfc6b882e044b8915b0ab5c0f212ee.doc",
          //url: "https://api.yxuer.com:8443/school-evaluation/newExcel/wordCheck/exportPropositionData?appuserId=61ab58e74a06043eb75c8d78&schoolExamId=677e730ddb8b547ad2b946c8&appId=YXUER_WEB&jsonBody=&userKey=fccce25bef99441b8a03e732f1ede9ec&schoolCode=SFI225.xls" //文件地址
        },
        editorConfig: {
            customization: {
              plugins: true, //定义插件是否启动和可用
            },
            
            lang: 'zh',
            location: 'us', //定义默认度量单位。 指定 us 或 ca 以设置英寸
            mode: 'edit', //定义编辑器打开模式
            plugins: { 
              pluginsData: [
                `https://api.yxuer.com:8443/static/yxuer/onlyofficeplugins/ai/config.json`
              ]
            }
          },
          type:'desktop'
      });
      
  
      /*此方法使用需要单独付费；否则不生效*/
      function insertText() {
        var connector  = docEditor.createConnector();
        connector.attachEvent("onChangeContentControl", function () {
          console.log("event: onChangeContentControl");
        });
        Asc.scope.text = "你好小明";
        connector.callCommand(
          () => {
            var oDocument = Api.GetDocument();
            var oParagraph = Api.CreateParagraph();
            oParagraph.AddText(Asc.scope.text);
            oDocument.InsertContent([oParagraph]);
          },
          () => {
            console.log("callback command");
          }
        );
      }
    </script>
  </body>
</html>
